// 定义数据库以及表结构
import type { SurveyDBData } from '@/types'
import Dexie, { type Table } from 'dexie'
class SurveyDataBase extends Dexie {
  // 定义survey类型：表示表的每一条记录是SurveyDbData类型，主键是number类型
  // !表示非空断言
  surveys!: Table<SurveyDBData, number>

  constructor() {
    super('SurveyDataBase')
    this.version(1).stores({
      surveys: '++id,createDate,updateData,title,surveyCount,coms',
    })
  }
}

const db = new SurveyDataBase()
export { db }
